var sum = prompt("请输入层数");
for(var j=1; j<=sum; j++){
    for(var nbsp = 0; nbsp<sum-j; nbsp++){
        document.write("&nbsp;");
    }
    for(var k=0; k<j*2-1; k++){
        document.write("*");
    }
    document.write("<br >");
}



